home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
.net 2002 March
/
DotNetMagazine-Issue107-Coverdisc-NET107-02-03-PCMac.bin
/
pc
/
PC Software
/
free_browsing
/
DavesQckSearchDbar3-14
/
dqsd.exe
/
src
/
DQSDTools
/
MenuBuilder.h
< prev
next >
Wrap
C/C++ Source or Header
|
2002-07-08
|
3KB
|
107 lines
// MenuBuilder.h : Declaration of the CMenuBuilder
#ifndef __MENUBUILDER_H_
#define __MENUBUILDER_H_
#include "resource.h" // main symbols
/////////////////////////////////////////////////////////////////////////////
// CMenuBuilder
class ATL_NO_VTABLE CMenuBuilder :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CMenuBuilder, &CLSID_MenuBuilder>,
public IObjectWithSiteImpl<CMenuBuilder>,
public ISupportErrorInfoImpl<&IID_IMenuBuilder>,
public IObjectSafetyImpl<CMenuBuilder, INTERFACESAFE_FOR_UNTRUSTED_CALLER>,
public IDispatchImpl<IMenuBuilder, &IID_IMenuBuilder, &LIBID_DQSDTOOLSLib>
{
public:
CMenuBuilder()
: m_nMenuItem( 0 )
, m_nHorizontalAlignment( EHorizontalAlignment::RIGHT )
{
m_hMain = ::CreatePopupMenu();
ATLTRACE("CMenuBuilder - created\n");
m_hTrackerWnd = NULL;
m_hTooltipWnd = NULL;
}
virtual ~CMenuBuilder()
{
if(m_hTrackerWnd != NULL)
{
DestroyWindow(m_hTrackerWnd);
}
if(m_hTooltipWnd != NULL)
{
DestroyWindow(m_hTooltipWnd);
}
ATLTRACE("CMenuBuilder - destroyed\n");
ATLTRACE("DQSDTools: Lock count %d\n", _Module.GetLockCount());
}
DECLARE_REGISTRY_RESOURCEID(IDR_MENUBUILDER)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(CMenuBuilder)
COM_INTERFACE_ENTRY(IMenuBuilder)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
COM_INTERFACE_ENTRY(IObjectWithSite)
COM_INTERFACE_ENTRY(IObjectSafety)
END_COM_MAP()
public:
STDMETHOD(SetSite)(IUnknown* pUnkSite);
// IMenuBuilder
public:
STDMETHOD(InitialiseTooltips)(long displayTimeMultiplier);
STDMETHOD(get_HorizontalAlignment)(/*[out, retval]*/ short *pVal);
STDMETHOD(put_HorizontalAlignment)(/*[in]*/ short newVal);
STDMETHOD(AppendSubMenu)(/*[in]*/ BSTR bstrName, VARIANT* pvParentMenu, /*[out,retval]*/ long* phmenu);
STDMETHOD(AppendMenuItem)(/*[in]*/ BSTR bstrItem, /*[in]*/ BSTR bstrKey, /*[in]*/ BSTR bstrToolTip, /*[in,optional]*/ VARIANT* pvhMenu);
STDMETHOD(AppendSeparator)(/*[in]*/ long hmenu);
STDMETHOD(Display)(LPDISPATCH pDispDocument, VARIANT* pbstrSelection);
// Implementation
protected:
static LPCTSTR DQSD_REG_KEY;
static LPCTSTR DQSD_SEC_KEY;
HMENU m_hMain;
int m_nMenuItem;
std::map< int, std::string > m_mapKeys;
std::map< int, std::string > m_toolTips;
UINT m_nHorizontalAlignment;
CComPtr<IHTMLWindow2> m_spIHTMLWindow2;
CComPtr<IHTMLDocument2> m_spIHTMLDoc2;
UINT getHorizontalPosition();
enum EHorizontalAlignment
{
CENTER,
LEFT,
RIGHT,
};
protected:
static LRESULT CALLBACK TrackerWndProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
HWND m_hTrackerWnd;
static HWND m_hTooltipWnd;
};
#endif //__MENUBUILDER_H_